#!/usr/bin/env python2


import subprocess, time, os, sys

def instanceFromFile(path):
	f = open(path)
	text = ""
	for line in f:
		text += line
	return text

def launch(input):
	command = ["./problema2-test"]
	subp = subprocess.Popen(command, stdout=subprocess.PIPE, stdin=subprocess.PIPE,	stderr=subprocess.STDOUT)
	stdout = subp.communicate(input=input)[0]
	return stdout.strip().split()

iterations = 1000
test_count = 100
tests = []

for test in range(test_count):
	tests.append("test-" + str(test+1) + ".txt")

for test in tests:
	instance = instanceFromFile(test)
	nodes, edges = instance.split("\n")[0].strip().split()
	nodes = int(nodes)
	edges = int(edges)
	solveA = 0
	solveB = 0

	for i in range(iterations):
		clocks = launch(instance)
		solveA += int(clocks[0])
		solveB += int(clocks[1])

	solveA = solveA / iterations
	solveB = solveB / iterations

	print str(nodes) + "\t" + str(edges) + "\t" + str(solveA) + "\t" + str(solveB)